package com.cx.bank.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration

public class MVCConfig implements WebMvcConfigurer {
    //视图解析器,thymeleaf添加的templates模板曜崽该解析器中声明
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/loginPage").setViewName("loginPage");
        registry.addViewController("/registerPage").setViewName("registerPage");
        registry.addViewController("/doRegisterSuccess").setViewName("doRegisterSuccessPage");

        registry.addViewController("/user/index").setViewName("user/index");
        registry.addViewController("/inquiry").setViewName("user/inquiry");
        registry.addViewController("/user/log").setViewName("user/log");
        registry.addViewController("/user/deposit").setViewName("user/deposit");
        registry.addViewController("/user/withDrawls").setViewName("user/withDrawls");
        registry.addViewController("/transfer").setViewName("user/transfer");
        registry.addViewController("/user/freezeUser").setViewName("user/freezeUser");
    }
    @Override
    public void addInterceptors(InterceptorRegistry registry){
        registry.addInterceptor(new LoginHandlerInterceptor()).addPathPatterns("/**")
                .excludePathPatterns("/loginPage","/doLogin","/login","/logOut","/register","/doRegister","/registerPage","/doRegisterSuccessPage");
    }
}